#ifndef __NETWORK_MYSQL_ERROR__
#define __NETWORK_MYSQL_ERROR__

#include <stdarg.h>
#include <glib.h>

#include "network-socket.h"
#include "chassis-exports.h"

/*line number alignment begins*/
/**/
/**/
/**/
/**/
/**/
/**/
/**/
/**/
/**/
/**/
/**/
/**/
/**/
/**/
/**/
/**/
/**/
/**定义错误编号*/
typedef enum {
	MPE_ERRCODE_START_FROM = 3000,
	MPE_PRX_PRCRQ_SQL_UNSAFE ,
	MPE_PRX_GETSRV_NO_BACKEND ,
	MPE_PRX_GETCON_TOO_MANY_CONNECTIONS ,
	MPE_PRX_GETCON_NO_CONNECTION_IN_POOL ,
	MPE_PRX_RAUTH_UNKNOWN_USER ,
	MPE_PRX_RAUTH_IP_NOT_ALLOWED ,
	MPE_PRX_RAUTH_PWD_SCRAMBLE_FAILED ,
	MPE_PRX_RAUTH_PWD_NOT_MATCHED ,
	MPE_PRX_RAUTH_TOO_MANY_FE_LOGINS ,
	MPE_ADM_RAUTH_UNKNOWN_USER ,
	MPE_ADM_RAUTH_PWD_SCRAMBLE_FAILED ,
	MPE_ADM_RAUTH_PWD_NOT_MATCHED ,
	MPE_PRX_GETCON_SPECIAL_QUERY ,
	MPE_PRX_RQRESULT_CONTEXT_RESTORE_FAILED ,
	MPE_PRX_RQ_TX_TIMEOUT ,
	MPE_PRX_RQ_PACKET_TOO_LARGE ,
	MPE_ADM_HSTMT_UNKNOWN_QUERY ,
	MPE_ADM_HSTMT_UNKNOWN_COMMAND ,
	MPE_ADM_CMDPRC_OPT_NOT_SPECIFIED ,
	MPE_ADM_CMDPRC_ELEMENT_ALREADY_EXISTS ,
	MPE_ADM_CMDPRC_SAVE_IN_XML_FAILED ,
	MPE_ADM_CMDPRC_ADD_BACKEND ,
	MPE_ADM_CMDPRC_ADD_LISTEN_SOCKET,
	MPE_ADM_CMDPRC_DEL_LISTEN_SOCKET,
	MPE_ADM_CMDPRC_ELEMENT_NOT_EXIST ,
	MPE_ADM_CMDPRC_PWD_NOT_MATCH ,
	MPE_ADM_CMDPRC_OPT_INVALID ,
	MPE_ADM_CMDPRC_CMD_SYNTAX_ERROR ,
	MPE_ADM_CMDPRC_CMD_OPT_IRRATIONAL ,
	MPE_ADM_CMDPRC_COMMAND_NOT_SUPPORT ,
	MPE_ADM_CMDPRC_COMMAND_NO_QUERY_SPECIFIED ,
	MPE_ADM_RQ_NEED_RESULTSET ,
	MPE_ADM_RQ_NEED_RESULTSET_SOMETHING,
	MPE_PRX_PRCRQ_SQL_TOO_MANY_PARA,
	MPE_ADM_CMDPRC_CMD_PROCESS_IN_MEM,
	MPE_PRX_PRCRQ_SQL_EXECUTE_TOO_LONG,
	MPE_PRX_PRCRQ_TOO_MANY_QUERY_IN_BYTES,
	MPE_PRX_PRCRQ_TOO_MANY_QUERY_OUT_BYTES,
	MPE_PRX_PRCRQ_TOO_MANY_QUERY_IN_NUM,
	MPE_PRX_PRCRQ_DB_SIZE_OUT_OF_LIMIT,
	MPE_PRX_PRCRQ_SQL_NOT_SUPPORT
} mpe_errcode_t;
/*line number alignment ends*/

typedef struct {
	mpe_errcode_t errcode;
	gchar *sqlstate;
	GString *errmsg;
} mpe_error_t;


NETWORK_API mpe_error_t *mpe_error_new(mpe_errcode_t errcode, va_list ap);
NETWORK_API void mpe_error_free(mpe_error_t *m);

NETWORK_API void mpe_log_error(mpe_errcode_t errcode, ...);
NETWORK_API void mpe_send_error(network_socket *con, mpe_errcode_t errcode, ...);


#endif /*__NETWORK_MYSQL_ERROR__*/

/*eof*/
